"""
实现温度的处理
华氏温度C和摄氏温度F的关系
C = 5*(F-32)/9 ---- F = 9*C/5+32

华氏温度C和开氏温度K的关系
K = C + 273.15
所以，K = 5*(F-32)/9 + 273.15
"""

# 摄氏温度F
class Temper_F:
    def __init__(self, Temper):
        self.F = Temper
        self.switch = {'F2C': self.F2C(), 'F2K': self.F2K()}

    def F2C(self):
        return 5 * (self.F - 32) / 9

    def F2K(self):
        return 5 * (self.F - 32) / 9 + 273.15

# 华氏温度C
class Temper_C:
    def __init__(self, Temper):
        self.C = Temper
        self.switch = {'C2F': self.C2F(), 'C2K': self.C2K()}

    def C2F(self):
        return 9 * self.C / 5 + 32

    def C2K(self):
        return self.C + 273.15

# 开氏温度K
class Temper_K:
    def __init__(self, Temper):
        self.K = Temper
        self.switch = {'K2C': self.K2C(), 'K2F': self.K2F()}

    def K2C(self):
        return 273.15 - self.K

    def K2F(self):
        return (273.15 - self.K) * 9 / 5 + 32


class switchover:
    @staticmethod
    def switchover(temp, method):
        return temp.switch[method]


F1 = Temper_F(10)
F2 = Temper_F(1000)
C1 = Temper_C(1002)

print(switchover.switchover(C1, 'C2F'))
print(switchover.switchover(C1, 'C2K'))
